﻿using MediatR;
using RBAC.Domain;
using RBAC.Domain.Service.Interfae;
using RBACDuYaJun.Api.Appliction.Command.UserCommand;


namespace RBACDuYaJun.Api.Appliction.CommandHandlers.UserHanders
{
    /// <summary>
    /// 添加用户信息
    /// </summary>
    public class UserCreateCommandHandler : IRequestHandler<UserCreateCommand, int>
    {
        private readonly IUserService _userService; 
        public UserCreateCommandHandler(IUserService userService)
        {
            _userService = userService;
        }

        public async Task<int> Handle(UserCreateCommand request, CancellationToken cancellationToken)
        {
            return await _userService.AddUser(new UserInfo()
            {
                userInfoName =request.userInfoName,
                password = request.password,
                userName = request.userName,
                userSex = request.userSex,
                provinceId = request.provinceId,
                cityId = request.cityId,
                countryId = request.countryId,
                userAddress = request.userAddress,
                departmentId = request.departmentId,
                addName="张三",
                addDate=DateTime.Now
                

            });
           
        }
    }
}
